using Identity.Application.Contracts.Services;
using Identity.Application.UserRoles.Commands;
using MediatR;

namespace Identity.Application.UserRoles.CommandHandlers;

public class GetUserRolesCommandHandler : IRequestHandler<GetUserRolesCommand, List<string>>
{
    
    private readonly IUserRoleService _userRoleService;

    public GetUserRolesCommandHandler(IUserRoleService userRoleService)
    {
        _userRoleService = userRoleService;
    }
    public async Task<List<string>> Handle(GetUserRolesCommand request, CancellationToken cancellationToken)
    {
        var roles = await _userRoleService.GetUserRolesAsync(request.userId);

        return roles.ToList();
    }
}